//---------------------------------------------------------------------------

#ifndef CComboModeleH
#define CComboModeleH
//---------------------------------------------------------------------------
#include <SysUtils.hpp>
#include <Controls.hpp>
#include <Classes.hpp>
#include <Forms.hpp>
#include "CComboBx.h"
#include <StdCtrls.hpp>
#include "CAccesCourrier.h"
//---------------------------------------------------------------------------

typedef void __fastcall (__closure *TComboModeleDrawItemEvent)(Controls::TWinControl* Control, int Index, const Windows::TRect &Rect, TOwnerDrawState State, const TDescriptifModele &DescriptifModele);
typedef int __fastcall(__closure *TDescriptifModeleSortCompare)(const TDescriptifModele &Modele1, const TDescriptifModele &Modele2);

class PACKAGE CComboModele : public CCustomComboBox
{
private:
  AnsiString FLogiciel;
  AnsiString FCategorie;
  AnsiString FModeleDefaut;
  AnsiString FRepDossier;
  short FIDModele;
  bool FSorted;
  TComboModeleDrawItemEvent FOnDrawItem;
  TDescriptifModeleSortCompare FOnSortCompare;
  TNotifyEvent FOnChange;
  HINSTANCE hEditeur;
  int Index;

  void __fastcall SetLogiciel(const AnsiString  aLogiciel);
  void __fastcall SetCategorie(const AnsiString  aCategorie);
  void __fastcall SetModeleDefaut(const AnsiString  aModeleDefaut);
  void __fastcall SetSorted(bool  bSorted);

  TStrings* __fastcall GetItems();
  void __fastcall Trier();
  void __fastcall Remplir();
  void __fastcall FctOnChange(System::TObject* Sender);
  void __fastcall FctOnDrawItem(Controls::TWinControl* Control, int Index,
                                const Windows::TRect &Rect, TOwnerDrawState State);
  void __fastcall SignalerUtilisationDuModele();

protected:
  void __fastcall WMDestroy(TMessage &Msg);
  void __fastcall WMAddString(TMessage &Msg);

  BEGIN_MESSAGE_MAP
   MESSAGE_HANDLER(WM_DESTROY, TMessage, WMDestroy)
   MESSAGE_HANDLER(CB_ADDSTRING, TMessage, WMAddString)
  END_MESSAGE_MAP(CCustomComboBox)
    // Déclaration des messages

public:
  __fastcall CComboModele(TComponent* Owner);
  virtual __fastcall ~CComboModele();
  TDescriptifModele GetDescriptifModele();

__published:
  __property              Anchors;
  __property AnsiString   Categorie = { read=FCategorie, write=SetCategorie };
  __property              DropDownCount;
  __property              DroppedDown;
  __property              Enabled;
  __property              Font;
  __property              HelpContext;
  __property              Hint;
  __property short        IDModele = { read=FIDModele, write=FIDModele };
  __property              IsEcranChaine;
  __property              ItemHeight;
  __property              Libelle;
  __property              *LibelleFont;
  __property AnsiString   Logiciel = { read=FLogiciel, write=SetLogiciel };
  __property AnsiString   ModeleDefaut = { read=FModeleDefaut, write=SetModeleDefaut };
  __property              ParentFont;
  __property              ParentShowHint;
  __property              PopupMenu;
  __property              ReadOnly;
  __property AnsiString   RepDossier = { read=FRepDossier, write=FRepDossier };
  __property              ShowHint;
  __property bool         Sorted = {read=FSorted, write=SetSorted, default = true};
  __property              SizeEspace;
  __property              Style;
  __property              TabOrder;
  __property              TabStop;
  __property              Text;
  __property              Visible;


  __property TComboModeleDrawItemEvent OnDrawItem = {read = FOnDrawItem,write = FOnDrawItem};
  __property TNotifyEvent OnChange = {read=FOnChange, write=FOnChange};
  __property TDescriptifModeleSortCompare OnCSortCompare = {read = FOnSortCompare,write = FOnSortCompare};
};
//---------------------------------------------------------------------------
#endif
